using System;
using System.Collections;
using System.Globalization;
using System.IO;
using Reflector.CodeModel;

namespace Reflector.CodeDom
{
    internal sealed class Helper
    {

        /// <summary>
        /// Gets the assembly reference.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static IAssemblyReference GetAssemblyReference(IType value)
        {
            ITypeReference typeReference = value as ITypeReference;
            if (typeReference != null)
            {
                ITypeReference owner = typeReference.Owner as ITypeReference;
                if (owner != null)
                {
                    return GetAssemblyReference(owner);
                }
                IModuleReference moduleReference = typeReference.Owner as IModuleReference;
                if (moduleReference != null)
                {
                    return moduleReference.Resolve().Assembly;
                }
                IAssemblyReference reference4 = typeReference.Owner as IAssemblyReference;
                if (reference4 != null)
                {
                    return reference4;
                }
            }
            throw new NotSupportedException();
        }


    }
}